﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework5
{
    [Serializable]
    public class Order
    {

        public Order()
        {
        }

        public Order(Customer customer,  int num, OrderDetails details)
        {
            Customer = customer;
            Num = num;
            Details = details;
            Money = details.Money;
        }

        public Customer Customer { get; set; }
        public int Num { get; set; }
        public OrderDetails Details { get; set; }
        public double Money { get; set; }

        public override bool Equals(object obj)
        {
            var order = obj as Order;
            return order != null &&
                   EqualityComparer<Customer>.Default.Equals(Customer, order.Customer) &&
                   Num == order.Num &&
                   EqualityComparer<OrderDetails>.Default.Equals(Details, order.Details) &&
                   Money == order.Money;
        }

        public override int GetHashCode()
        {
            var hashCode = 319680176;
            hashCode = hashCode * -1521134295 + EqualityComparer<Customer>.Default.GetHashCode(Customer);
            hashCode = hashCode * -1521134295 + Num.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer<OrderDetails>.Default.GetHashCode(Details);
            hashCode = hashCode * -1521134295 + Money.GetHashCode();
            return hashCode;
        }
    }
}
